//! AI Test Platform - A modern, AI-driven testing framework
//! 
//! This platform combines the mature architecture of HttpRunner with the high-performance
//! actor model of coerce-rs, enhanced with AI capabilities from Lumos.ai and multi-language
//! plugin support through Extism.

pub mod actors;
pub mod ai;
pub mod api;
pub mod cli;
pub mod config;
pub mod dsl;
pub mod error;
pub mod models;
pub mod plugins;
pub mod protocols;
pub mod runners;
pub mod steps;
pub mod storage;
pub mod utils;
pub mod validation;

// Re-export commonly used types
pub use error::{Error, Result};
pub use models::{
    testcase::{ITestCase, TestCase},
    config::{TestConfig, StepConfig},
    step::{IStep, StepType, StepResult},
    request::{HttpRequest, HttpMethod},
    summary::{TestSummary, TestCaseSummary},
};
pub use dsl::{
    DSLParser, TemplateEngine, VariableManager, FunctionRegistry,
    TestCaseDefinition, ConfigDefinition, StepDefinition,
};

// Version information
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const NAME: &str = env!("CARGO_PKG_NAME");
pub const DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION");

/// Initialize the platform with default configuration
pub async fn init() -> Result<()> {
    // Initialize logging
    utils::logger::init()?;
    
    // Initialize configuration
    config::init().await?;
    
    // Initialize metrics
    utils::metrics::init()?;
    
    tracing::info!("AI Test Platform v{} initialized", VERSION);
    Ok(())
}

/// Platform information
#[derive(Debug, Clone, serde::Serialize)]
pub struct PlatformInfo {
    pub name: &'static str,
    pub version: &'static str,
    pub description: &'static str,
    pub rust_version: &'static str,
    pub build_time: &'static str,
}

impl Default for PlatformInfo {
    fn default() -> Self {
        Self {
            name: NAME,
            version: VERSION,
            description: DESCRIPTION,
            rust_version: env!("RUSTC_VERSION"),
            build_time: env!("BUILD_TIME"),
        }
    }
}

/// Get platform information
pub fn platform_info() -> PlatformInfo {
    PlatformInfo::default()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[tokio::test]
    async fn test_platform_init() {
        let result = init().await;
        assert!(result.is_ok());
    }

    #[test]
    fn test_platform_info() {
        let info = platform_info();
        assert_eq!(info.name, NAME);
        assert_eq!(info.version, VERSION);
        assert!(!info.rust_version.is_empty());
    }
}
